<?php
namespace app\models;

use yii;
use yii\db\Query;
use app\lib\Redis;
/**
 *收款方式paypal,T/T,西联，邮政
 */
class Income_type
{
	use Redis;

	private $table;

	private $redis;

	public function __construct() 
	{
		$this->table = yii::$app->db->tablePrefix."income_type";
		$this->redis = $this->getInstance();
	}

    public function get_all_types()
    {
    	$redisKey = 'income:type';//收入来源方式
    	if ($list = $this->redis->get($redisKey)) {
    		return json_decode($list,true);
    	} else {
    		$db = new QUery();
    		$list = $db->select('*')->from($this->table)->all();
    		$this->redis->setex($redisKey,3600*24,json_encode($list));
    		return $list;
    	}

    }
}
